﻿namespace WMS6.Web.Common
{
    using System;
    using System.Data;
    using System.Text;
    using WMS6.Web;

    public class RelatedOrdersAjax : BasePage
    {
        private void AssignFunctionResponse(string m_AssignFunctionData)
        {
            base.Response.Clear();
            base.Response.StatusCode = 200;
            base.Response.StatusDescription = "OK";
            base.Response.ContentType = "text/html";
            base.Response.Write(m_AssignFunctionData);
            base.Response.Flush();
            base.Response.End();
        }

        public void CreatedHtml(DataSet ds)
        {
            StringBuilder strDiv = new StringBuilder();
            strDiv.Append("<table width=\"500\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"34\" background=\"../Images/slotbg_01.gif\"><table width=\"94%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><span class=\"warehoustitle\">详细信息</span></td><td width=\"16\" class=\"close\" onclick=\"DivClose();\">&nbsp;</td></tr></table></td></tr>");
            strDiv.Append("<tr><td height=\"22\" background=\"../Images/slotbg_03.gif\"><table width=\"90%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"0\">");
            if (((ds != null) && (ds.Tables.Count > 0)) && (ds.Tables[0].Rows.Count > 0))
            {
                for (int i = 0; ds.Tables[0].Rows.Count > i; i++)
                {
                    strDiv.AppendFormat("  <tr><td width=\"10%\" class=\"areaname\">单号：</td><td class=\"areamessage\">{0}</td><td width=\"15%\" class=\"areaname\">数量：</td> <td class=\"areamessage\">{1}</td></tr>", ds.Tables[0].Rows[i]["ORDER_ID"].ToString(), base.GetPreferenceDigit(ds.Tables[0].Rows[i]["QTY"].ToString()));
                }
            }
            else
            {
                strDiv.AppendFormat("  <tr><td align=\"center\"  style=\"color:Red\">未找到对应的记录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr> ", new object[0]);
            }
            strDiv.Append(" </table></td></tr>");
            strDiv.Append("<tr><td height=\"7\" background=\"../Images/slotbg_02.gif\"></td></tr>");
            strDiv.Append("<tr><td height=\"18\" background=\"../Images/slotbg_04.gif\">&nbsp;</td></tr></table>");
            this.AssignFunctionResponse(strDiv.ToString());
        }

        public void Load_Date()
        {
            DataSet ds = CommoneMethodServiceClientProxy.GetInstance().GetRelatedOrders(base.Request.QueryString["type"], base.Request.QueryString["skuID"], base.Request.QueryString["ownerID"], base.Request.QueryString["lot"], base.Request.QueryString["loc"], base.Request.QueryString["lpn"]);
            this.CreatedHtml(ds);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["type"]))
            {
                this.Load_Date();
            }
        }
    }
}

